<?php
// +----------------------------------------------------------------------
// | my
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: $this <498944516@qq.com>
// +----------------------------------------------------------------------
namespace app\rob\model;

use think\Model;

class RobAppDo extends Model
{

    protected $table = "my_rob_app_do";
    protected $insert = ['status'=>1];  
    protected $autoWriteTimestamp = true;

    /**
     * 返回app处理规则
     */
    public function index($data){
    	
      //处理找到合适的回复
      //只有关键字
      //有前面无后面
      //有前面后面需要分割
    

      $map['app']=$data['app']['id'];
      if(!$data['before']){
       $map['before']=0; 
       }elseif(is_numeric($data['before'])) {
       $map['before']=1; 
      } else {
       $map['before']=$data['before'];
      }

       if(!$data['back']){
       $map['back']=0; 
       }else {
       $map['back']=1; 
      }
       
      $do=$this->where($map)->find();
      mylog($do);
      if ($do['model'] and $do['action']) $reply=model($do['model'])->$do['action']($data);
      
      return $reply;
    		   
    }

   



    public function editData(){

      $data=input("post.");
     
      if ($data['id']){
         $res = $this->allowField(true)->where('id',$data['id'])->update($data);
      }else{
         $data['aid']=session('aid');
         $res = $this->allowField(true)->data($data)->save();
      }
      
      return $res;
    }



    
}